package com.zlk.algorithm.algorithm.base;

/**
 * @program: algorithm
 * @ClassName Code01_GcdAndLcm
 * @description:
 * @author: slfang
 * @create: 2024-10-15 15:09
 * @Version 1.0
 **/
public class Code01_GcdAndLcm {

    public static void main(String[] args) {
        //
        System.out.println(gcd(20, 30));
        System.out.println(lcm(20, 30));

    }

    /**
     * 最大公约数
     * @param a
     * @param b
     * @return
     */
    public static long gcd(long a, long b){
        return b==0?a:gcd(b,a%b);
    }

    /**
     * 最小公倍数
     * @param a
     * @param b
     * @return
     */
    public static long lcm(long a, long b) {
        return (long) a / gcd(a, b) * b;
    }


}
